﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcs.Web.Outstorage
{
    public partial class ListSHWTG : Web.Admin.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["login"] != null)
                {
                    DataSet ds = Session["login"] as DataSet;

                    int roles_id = Convert.ToInt32(ds.Tables[0].Rows[0]["roles_id"].ToString());
                    int user_id = Convert.ToInt32(ds.Tables[0].Rows[0]["user_id"].ToString());

                    if (roles_id == 3)//材料员
                    {
                        Bind(user_id);
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('您不是材料员！');</script>");
                    }
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this, "由于长时间未操作，登录信息已过期，请重新登陆!");
                }


            }

        }


        private void Bind(int user_id)
        {
            DataSet ds = new lcs.BLL.user_project().GetUserPros(" user_id=" + user_id + " and check_status='审核未通过' ");//获取审核未通过的此材料员提交的出库单

            this.GridView1.DataSource = ds;
            this.GridView1.DataBind();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "lbn_del")
            {
                if (e.CommandArgument != null)
                {
                    int out_storageList_id = Convert.ToInt32(e.CommandArgument.ToString());

                    if (new lcs.BLL.out_storageList().Delete(out_storageList_id))
                    {

                        if (Session["login"] != null)
                        {
                            DataSet ds = Session["login"] as DataSet;

                            int roles_id = Convert.ToInt32(ds.Tables[0].Rows[0]["roles_id"].ToString());
                            int user_id = Convert.ToInt32(ds.Tables[0].Rows[0]["user_id"].ToString());

                            if (roles_id == 3)//材料员
                            {
                                Bind(user_id);
                            }
                            
                        }
                    }

                }
            }
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行
            {
                //当鼠标放上去的时候 先保存当前行的背景颜色 并设置新的背景色
                e.Row.Attributes.Add("onmouseover", "onmouseroverop(this)");
                //当鼠标离开的时候 将背景颜色恢复成之前的颜色
                e.Row.Attributes.Add("onmouseout", "onmouseroutop(this)");
                //单击行改变行背景颜色
                e.Row.Attributes.Add("onclick", "ItemOver(this)");
            }
        }
    }
}